package edu.tongji.libraryapp.adapter;

import java.util.ArrayList;

import edu.tongji.libraryapp.R;
import edu.tongji.libraryapp.model.CurrentBorrow;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class CurrentBorrowListAdapter extends BaseAdapter {

	private ArrayList<CurrentBorrow> currentBorrowList;
	private Context appContext;
	private Context activityContext;

	public CurrentBorrowListAdapter(Context appContext,
			Context activityContext, ArrayList<CurrentBorrow> currentBorrowList) {
		this.setAppContext(appContext);
		this.setActivityContext(activityContext);
		this.currentBorrowList = currentBorrowList;
	}

	@Override
	public int getCount() {
		return currentBorrowList.size();
	}

	@Override
	public Object getItem(int position) {
		return currentBorrowList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			LayoutInflater mInflater = (LayoutInflater) appContext
					.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(R.layout.current_borrow_list_item,
					null);
		}
		return convertView;
	}

	public ArrayList<CurrentBorrow> getCurrentBorrowList() {
		return currentBorrowList;
	}

	public void setHistoryBorrowList(ArrayList<CurrentBorrow> currentBorrowList) {
		this.currentBorrowList = currentBorrowList;
	}

	public Context getAppContext() {
		return appContext;
	}

	public void setAppContext(Context appContext) {
		this.appContext = appContext;
	}

	public Context getActivityContext() {
		return activityContext;
	}

	public void setActivityContext(Context activityContext) {
		this.activityContext = activityContext;
	}
}
